package com.lwq.im.chartdemo.bean;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {


    public static final String SUCCESS_CODE = "200";
    public static final String SUCCESS_MESSAGE = "success";

    public static final String ERROR_CODE = "500";
    public static final String ERROR_MESSAGE = "error";

    private String code;

    private String message;

    private T body;



    public static CommonResult success(){
        return new CommonResult(SUCCESS_CODE, SUCCESS_MESSAGE, null);
    }

    public static <T> CommonResult success(String message, T body){
        return new CommonResult(SUCCESS_CODE, message, body);
    }

    public static <T> CommonResult success(T body){
        return new CommonResult(SUCCESS_CODE, SUCCESS_MESSAGE, body);
    }

    public static CommonResult error(){
        return new CommonResult(ERROR_CODE, ERROR_MESSAGE, null);
    }

    public static <T> CommonResult error(String message, T body){
        return new CommonResult(ERROR_CODE, message, body);
    }

    public static CommonResult error (String message){
        return new CommonResult(ERROR_CODE, message, null);
    }



}
